1 import std.datetime : SysTime, Date; 2 import toml.datetime : DateTime, TimeOfDay; 3 4 assert(toJSON(TOMLValue("string")).str == "string"); 5 assert(toJSON(TOMLValue(42)) == JSONValue(42)); 6 assert(toJSON(TOMLValue(.1)) == JSONValue(.1)); 7 assert(toJSON(TOMLValue(SysTime.fromISOExtString("1979-05-27T07:32:00Z"))) 8 .str == "1979-05-27T07:32:00Z"); 9 assert(toJSON(TOMLValue(DateTime.fromISOExtString("1979-05-27T07:32:00"))) 10 .str == "1979-05-27T07:32:00"); 11 assert(toJSON(TOMLValue(Date.fromISOExtString("1979-05-27"))).str == "1979-05-27"); 12 assert(toJSON(TOMLValue(TimeOfDay.fromISOExtString("07:32:00"))).str == "07:32:00"); 13 assert(toJSON(TOMLValue([1, 2, 3])) == JSONValue([1, 2, 3])); 14 assert(toJSON(TOMLDocument(["a" : TOMLValue(0), "b" : TOMLValue(1)])) == JSONValue(["a" 15 : 0, "b" : 1])); 16 assert(toJSON(TOMLValue(true)).type == JSON_TYPE.TRUE); 17 assert(toJSON(TOMLValue(false)).type == JSON_TYPE.FALSE);
Converts a TOMLValue to a JSONValue. Note: datetimes are converted to strings.